package com.xmler.plugin.adbrocket.ui.renderer

import com.xmler.plugin.adbrocket.bean.ComboDeviceBean
import java.awt.Component
import javax.swing.JLabel
import javax.swing.JList
import javax.swing.ListCellRenderer

class DeviceComboBoxRenderer: JLabel(), ListCellRenderer<ComboDeviceBean> {
    override fun getListCellRendererComponent(
        list: JList<out ComboDeviceBean>?,
        value: ComboDeviceBean?,
        index: Int,
        isSelected: Boolean,
        cellHasFocus: Boolean
    ): Component {
        value ?: return this
//        val splitIndex = value.name.indexOf("Android")
//        val sb = StringBuilder("<html>")
//        sb.append("<font color='#bbbbbb'>").append(value.name.substring(0, splitIndex)).append("</font>")
//        sb.append("<font color='#888888'>").append(value.name.substring(splitIndex)).append("</font>")
//        sb.append("</html>")
//        this.text = sb.toString()
        this.text = value.name
        return this
    }
}